<template>
	<view :style="Theme">
		<uni-nav-bar leftIcon="arrowleft" :fixed="true" title="注册" />
		<view class="logo">
			<image src="/static/logo.jpg"></image>
		</view>
		<view class="content">
			<view class="row-input">
				<i class="iconfont icon-verCode" />
				<input placeholder="请输入用户名" maxlength="11" v-model="form.username" />
			</view>
			<view class="row-input">
				<i class="iconfont icon-shouji" />
				<input placeholder="请输入手机号码" maxlength="11" v-model="form.mobile" />
			</view>
			<view class="row-input">
				<i class="iconfont icon-mima" />
				<input placeholder="请输入您的密码" maxlength="16" v-model="form.password" />
			</view>
			<view class="row-input">
				<i class="iconfont icon-mima" />
				<input placeholder="请再次输入您的密码" maxlength="16" v-model="form.repassword" />
			</view>
			<view class="register-btn" @click="handleRegister">注册</view>
			<view class="tip-link">
				<view style="display: flex;">
					<checkbox-group @change="handleChange">
						<checkbox :value="isChecked" style="transform: scale(0.6);" color="var(--primary-color)" />
					</checkbox-group>
					<text>我已阅读并同意</text>
					<text class="link" @click="handleYin">《隐私保护协议》</text>
				</view>
				<navigator url="/sub_intake/pages/login/login" class="qudengl">去登录</navigator>
			</view>
		</view>
		<uni-popup ref="popup" background-color="#fff">
			<view class="popup-content">
				<view class="qiye1">隐私保护协议</view>
				<view class="qiye2">隐私保护协议。。。。</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import alert from '@/common/sju.alert.js'
	export default {
		data() {
			return {
				form:{
					username:'',
					mobile:'',
					password:'',
					repassword:''
				},
				isChecked:false
			}
		},
		components: {
			
		},
		onLoad() {

		},
		onShow() {
			
		},
		methods: {
			handleChange(e) {
			  this.isChecked = !e.detail.value[0];
			  this.isChecked = !this.isChecked
			  console.log(this.isChecked)
			},
			handleYin(){
				this.$refs.popup.open()
			},
			handleRegister(){
				if(this.form.username===''||this.form.mobile===''||this.form.password===''||this.form.repassword===''){
					alert.showInfo('请填写完整')
				}else if(!this.isChecked){
					console.log('走了吗')
					alert.showInfo('请先阅读协议并勾选')
				}else{
					this.sjuRequest("/wx/auth/wxRegister", 'POST', this.form ).then(res => {
						console.log(res)
						if(res.errno!=0){
							alert.showInfo(res.errmsg)
						}else{
							uni.showToast({
								title: '注册成功',
								icon: 'success',
								duration: 2000
							})
							setTimeout(function(){
								uni.reLaunch({
									url:'/sub_intake/pages/login/login'
								})
							},2000)
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.logo{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		height: 300rpx;
		image{
			width: 200rpx;
			height: 200rpx;
			border: 1px solid #eee;
			border-radius: 100%;
		}
	}
	
	.content {
		padding: 40rpx;
	
		.row-input {
			margin: 30rpx 0rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			padding: 0 20rpx;
			height: 100rpx;
			border: 1rpx solid var(--primary-color);
			border-radius: 20rpx;
			
			image {
				padding: 0rpx 10rpx 0rpx 10rpx;
				width: 50rpx;
				height: 50rpx;
				flex-shrink: 0;
			}
			
			.iconfont {
				color: var(--primary-color);
				padding: 0rpx 10rpx 0rpx 10rpx;
				flex-shrink: 0;
				font-size: 40rpx;
			}
	
			input {
				flex: 1;
				font-size: 30rpx;
				padding: 0rpx 40rpx;
				color: var(--primary-color);
				border-left: 3rpx solid var(--primary-color);
			}
	
			.code {
				display: flex;
				justify-content: flex-end;
				letter-spacing: 2rpx;
				width: 180rpx;
				color: var(--primary-color);
			}
		}
	
		.register-btn {
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 35rpx;
			height: 100rpx;
			margin: 40rpx 0 40rpx 0;
			border-radius: 20rpx;
			color: #FFFFFF;
			background-color: var(--btn-bg-color);
		}
		
		.tip-link{
			display: flex;
			justify-content: space-between;
			align-items: center;
			letter-spacing: 4rpx;
			font-size: 28rpx;
			
			.link{
				color: var(--primary-color);
			}
			
		}
	}
	.qudengl{
		color: var(--btn-bg-color);
		border-bottom:1rpx solid var(--btn-bg-color);
	}
	.popup-content{
		width: 600rpx;
		height: 800rpx;
		background: #fff;
		border-radius: 16rpx;
		padding: 20rpx;
		text-align: center;
		padding-bottom: 40rpx;
		overflow: auto;
	}
		
	.qiye1{
		font-size: 32rpx;
		margin-bottom: 10rpx;
	}
	.qiye2{
		text-align: left;
	}
</style>
